package com.ehotting.edsta.csharpServer.controller;

import com.ehotting.eaf.core.constant.SecurityConstants;
import com.ehotting.eaf.core.domain.R;
import com.ehotting.eaf.core.enums.SimulationTypeEnum;
import com.ehotting.eaf.core.web.controller.BaseController;
import com.ehotting.eaf.core.web.domain.AjaxResult;
import com.ehotting.edsta.common.log.annotation.Log;
import com.ehotting.edsta.common.log.enums.BusinessType;
import com.ehotting.edsta.csharpServer.domain.vo.AppVersionVo;
import com.ehotting.eaf.core.domain.system.api.AppVersion;
import com.ehotting.edsta.csharpServer.service.IAppVersionService;
import com.ehotting.edsta.system.api.RemoteVersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/init")
@Api(tags = "InitController",description = "C端初始化接口")
public class InitController extends BaseController {

    @Autowired
    private IAppVersionService appVersionService;

    @Autowired
    private RemoteVersionService remoteVersionService;


    @Log(title = SimulationTypeEnum.MAIN_SOFTWARE_NAME, businessType = BusinessType.OTHER)
    @ApiOperation("C端版本校验")
    @PostMapping
    public R<AppVersionVo> init(@RequestBody AppVersion appVersion){
        AppVersionVo result = appVersionService.init(appVersion);
        return R.ok(result);
    }

    @Log(title = SimulationTypeEnum.MAIN_SOFTWARE_NAME, businessType = BusinessType.GET_DATA)
    @ApiOperation("获取最新版本信息（Windows）")
    @GetMapping("/getLatestInfo")
    public R<AppVersion> getLatestInfo(){
        return remoteVersionService.getLatestInfo("Windows",SecurityConstants.INNER);
    }

    @Log(title = SimulationTypeEnum.MAIN_SOFTWARE_NAME, businessType = BusinessType.GET_DATA)
    @ApiOperation("获取最新版本信息（Linux）")
    @GetMapping("/getLatestInfo4Linux")
    public R<AppVersion> getLatestInfo4Linux(){
        return remoteVersionService.getLatestInfo("Linux",SecurityConstants.INNER);
    }


}
